lass Solution {
public:
    ListNode* swapPairs(ListNode* head) {
if(head==nullptr||head->next==nullptr)return head;
        ListNode* newhead = new ListNode(-1,head);
        ListNode* temp = newhead;
        ListNode* newnext = newhead;
        ListNode* newbehind = head;
        while(temp->next!=nullptr&&temp->next->next!=nullptr){
            newnext = temp->next;
            newbehind = temp->next->next;
            temp->next = newbehind;
            newnext->next = newbehind->next; 
            newbehind->next = newnext;
            temp = newnext;
        }
        return newhead->next;
    }
};